package com.angzh.bolibao.config;

import com.angzh.bolibao.model.Brand;
import com.angzh.bolibao.model.Clicks;
import com.angzh.bolibao.model.Commission;
import com.angzh.bolibao.model.Customer;
import com.angzh.bolibao.model.User;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;

/**
 * 
 * @author yangsl
 * 
 * @description 全部配置信息
 * 
 * **/
public class Config extends JFinalConfig{

	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setViewType(ViewType.JSP);
	}

	@Override
	public void configRoute(Routes me) {
		me.add(new RootRoute());
		
	}

	@Override
	public void configPlugin(Plugins me) {
		loadPropertyFile("application.properties");
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password"));
		c3p0Plugin.setDriverClass(getProperty("driverClass"));
		me.add(c3p0Plugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.addMapping("user", User.class);
		arp.addMapping("customer", Customer.class);
		arp.addMapping("commission", Commission.class);
		arp.addMapping("clicks", Clicks.class);
		arp.addMapping("brand", Brand.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		
	}

}
